home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d19
/
add2bbs.arc
/
ADD2BBS.C
next >
Wrap
Text File
|
1990-10-17
|
38KB
|
1,063 lines
/* #define DEBUG */
/*
╔══[ MS-DOS ! ]═════════════════════════════════════════════════════════════╗
║ ║
║ - ADD2BBS.C R.Cougnenc 1990 - Public Domain - ║
║ ║
╟───────────────────────────────────────────────────────────────────────────╢
║ ║
║ This program moves the newly downloaded files and their descriptions ║
║ to the specified file directory and description file. ║
║ ║
║ Files are MOVED and do not remain in the source dir. ║
║ ║
║ Specially designed for Attila ALTAN, sysop of LI'LL BBS, Paris France. ║
║ ║
║ Compile: Microsoft-C or Turbo-C. ║
║ ║
║ ║
╚═══════════════════════════════════════════════════════════════════════════╝
The executable distribution file is compiled with MS-C, using Large Model.
This allows the use of the total memory to store the filenames to process,
and all screen outputs going to stdout.
If you use Turbo-C, the #defines should make a program writing directly
to the screen memory, this is a lot faster, but not a good solution for
such a program.
I took me just one day to write this program, it is certainly not
perfect...
Feel free to correct all bugs !
*/
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <errno.h>
#include <dos.h>
#include <stdlib.h>
#include <process.h>
#include <io.h>
#include <share.h>
#ifndef __TURBOC__
#include <sys/types.h>
#include <memory.h>
#else
#include <mem.h>
#include <dir.h>
#include <conio.h>
#define printf cprintf
#endif
#include <sys/stat.h>
#include "add2bbs.h"
/*-----------------------( Global variables )-----------------------------*/
struct Ftype *Fstru ;
FILE *dfile ;
char ScanDir [ 256 ] , /* Ready for Posix :-) */
ScanPath [ 256 ] ,
FileDes [ 256 ] ,
DestDir [ 256 ] ,
FileList [ 256 ] ,
ConfPath [ 256 ] ,
TmpFile [ 256 ] ,
ExtCommand [ 256 ] ,
CmTab [ MAX_C_LINES ][ MAX_C_COLS+1 ];
int nbfiles ;
/*----------------------( main program )------------------------------------*/
int main(int argc,char **argv)
{
int result;
Title();
if( argc == 1 ) /* No argument, use configuration file */
{
MakeConfPath(argv[0]);
if( ! ReadConf() )
return(0xFF);
}
else
{
if( argc != 5 )
{
Usage();
return( 0xFF);
}
strcpy( ScanDir , argv[1] );
strcpy( FileDes , argv[2] );
strcpy( DestDir , argv[3] );
strcpy( FileList , argv[4] );
}
if( ! VerifPath() )
return(0xFF);
if(! (nbfiles = FindFiles()) )
{
printf("%s : No file found.\n",ScanDir );
return( 0xFF );
}
if ( (dfile = fopen( TmpFile,"a+")) == NULL )
{
printf("Unable to open file %s !\n",FileList);
return (0xFF);
}
ListFiles(ALL);
if( (result = ReadDesc() ) != nbfiles )
ListFiles(NOTFOUND);
fclose(dfile);
if( result )
{
if( fappend( FileList,TmpFile ) )
{
printf("Unable to update file %s !\n",FileList );
printf("Comments remaining in %s.\n",TmpFile);
return(0xFF);
}
printf("%s",result == nbfiles ? "Update Sucessfull.\n"
: "All new files successfully added.\n");
}
else
{
unlink(TmpFile);
printf("No file added.\n");
}
return( 0 );
}
/*-------------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ FINDFILES : Creates a linked list with all the files found in the │
│ search directory. │
│ │
│ Return : Number of files found. │
╘════════════════════════════════════════════════════════════════════════╛
*/
int FindFiles (void)
{
int i = 0 ;
static char *Pattern = "*.*" ;
static char *ErrMsg = "Findfiles(): Cannot allocate memory for %d bytes\n";
struct Ftype *WorkStru;
int echar ;
struct DocFile
{ /* My own struct since Borland */
char Reserved[21]; /* and Microsoft use different */
char attribut; /* names... */
unsigned Time; /* Don't worry about warnings! */
unsigned Date;
long Taille;
char name[13];
}
SearchBlock;
echar = (int) ScanDir[strlen(ScanDir) -1] ;
if( echar && echar != '\\' && echar != '/' && echar != ':' )
strcat(ScanDir,"\\");
strcpy(ScanPath,ScanDir); /* Save it for later use..., */
strcat(ScanDir,Pattern); /* and add the search pattern. */
Fstru = (struct Ftype *) malloc ( sizeof (struct Ftype) );
if( Fstru == NULL )
{
printf(ErrMsg, sizeof( struct Ftype) );
return( 0 );
}
WorkStru = Fstru;
#ifdef __TURBOC__
if (findfirst (ScanDir,&SearchBlock,0) == 0)
#else
if (_dos_findfirst (ScanDir, _A_ARCH, &SearchBlock) == 0)
#endif
{
do
{
WorkStru->Next =(struct Ftype * ) NULL;
WorkStru->HasComment = 0 ;
strcpy( WorkStru->fname, SearchBlock.name );
strlwr( WorkStru->fname ); /* I prefer lower case !!! */
i++;
WorkStru->Next = (struct Ftype *) malloc ( sizeof (struct Ftype) );
if( WorkStru->Next == NULL )
{
printf(ErrMsg, sizeof( struct Ftype) );
return(i);
}
WorkStru = WorkStru -> Next;
WorkStru ->Next = (struct Ftype * ) NULL;
}
#ifdef __TURBOC__
while(findnext (&SearchBlock) == 0 );
#else
while (_dos_findnext (&SearchBlock) == 0);
#endif
}
else return 0 ;
return i ;
}
/*-------------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ LISTFILES: Displays the files in the linked list. │
│ │
╘════════════════════════════════════════════════════════════════════════╛
*/
void ListFiles(int which)
{
struct Ftype *WorkStru;
int i = 0 ;
int nb = 0 ;
WorkStru = Fstru ;
if( which == ALL )
printf("──────> Files found in %s <──────────────\n\n",ScanDir);
if( which == NOTFOUND )
printf("──────> Files not found in %s <──────────────\n\n",FileDes);
while( WorkStru -> Next != (struct Ftype *) NULL )
{
if( which == ALL ||(which == NOTFOUND && ! WorkStru -> HasComment ))
{
printf("%-15s",WorkStru -> fname );
i++;
nb++;
if( i > 4 )
{
printf("\n");
i = 0 ;
}
}
WorkStru = WorkStru -> Next ;
}
printf("\n\n─────> %d Files.\n\n",nb);
}
/*-------------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ FLAGFILE : Moves the file in the destination directory if it is │
│ found in the linked list, │
│ Copies its description to the destination file list, │
│ and flags the corresponding structure as commented ok. │
│ │
│ Return : 1 if the file was in the list │
│ 0 if not. │
╘════════════════════════════════════════════════════════════════════════╛
*/
int FlagFile(char *line )
{
struct Ftype *WorkStru;
WorkStru = Fstru ;
while( WorkStru -> Next != (struct Ftype *) NULL )
{
if ( ! strnicmp (line,WorkStru-> fname,strlen(WorkStru->fname) ) )
{
if( MoveFile(WorkStru -> fname) )
{
printf("───── Found : %s ───────────────────────\n",WorkStru -> fname );
PrintTab();
WorkStru -> HasComment = 1 ; /* Ok files is moved. */
printf("─────■ File moved. ■──────────────────────"
"────────────────────────────────────\n\n");
printf("\nScanning %s..\r",FileDes);
}
return( 1 ); /* Was in the list */
}
WorkStru = WorkStru -> Next ;
}
return( 0 ); /* Was'nt in the list */
}
/*-----------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ READDESC: Scans the source description file, and if a file of the │
│ linked list matches, calls FlagFile in order to process │
│ it. │
│ │
│ Return : Number of files found │
│ 0 on error. │
╘════════════════════════════════════════════════════════════════════════╛
*/
int ReadDesc(void)
{
FILE *fp;
char tmp[256];
int i,count = 0;
if( (fp = fopen(FileDes,"r")) == NULL )
{
printf("Unable to open description file %s\n",FileDes);
return( 0 );
}
setvbuf(fp,NULL,_IOFBF,MYBUFS);
printf("\nReading %s..\r",FileDes);
while(fgets(tmp,256,fp) )
{
Clean(tmp);
test_it:
if( ! IsFilDes(tmp)) continue; /* Search for the 1st comment line */
else
{
i = 0 ;
ClearTab();
strcpy(CmTab[i],tmp );
while(fgets(tmp,256,fp) ) /* read comments */
{
i++;
Clean(tmp);
if ( ! IsComment(tmp)) /* until last one */
{
#ifdef DEBUG
PrintTab();
#endif
if( FlagFile( CmTab[0] ) )
count++;
if( count == nbfiles) /* end of process*/
return(count) ;
goto test_it;
}
else strcpy(CmTab[i],tmp );
}
}
}
fclose( fp );
return(count);
}
/*------------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ ISFILDES : Tries to determine if the line is the 1st description │
│ line of a file. │
│ │
│ Return : 0 if it does not begin with a valid filename │
│ 1 if it does. │
│ │
│ Assumes valid names beginning column 0, containing an │
│ extension, and composed with ASCII characters. │
╘════════════════════════════════════════════════════════════════════════╛
*/
int IsFilDes( char *line)
{
char name[15];
char *ptr;
strncpy(name,line,12);
name[12] = 0 ;
strupr( name);
if( ! strchr(name, '.') ) return ( 0 ); /* If no extension, not */
/* a filename. */
/* If invalid chars, */
/* not a filename... */
ptr = name;
while(*ptr)
{
if (*ptr < 32 || *ptr > 90 ) return ( 0 );
ptr ++;
}
return ( 1 );
}
/*------------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ ISCOMMENT : Tries to determine if the line is an additionnal │
│ description line. │
│ │
│ Return : 1 if it is one, │
│ 0 if not. │
│ │
│ Assumes valid additionnal description lines begin with │
│ a minimum of 30 space chars. │
╘════════════════════════════════════════════════════════════════════════╛
*/
int IsComment(char *line)
{
register int i;
for(i=0; i < 30; i++)
{
if (! *line) return( 0 );
if (*line != 32) return( 0 );
line++;
}
return(1);
}
/*----------------------------------------------------------------------*/
/*
┌──────────────────────────────────────────────────────┐
│ CLEAN : Fixes the normalized bug of fgets() :-) │
└──────────────────────────────────────────────────────┘
*/
void Clean( char *line)
{
int i;
i = strlen(line) - 1;
if(line[i] == '\n');
line[i] = 0 ;
}
/*----------------------------------------------------------------------*/
/*
┌──────────────────────────────────────────────────────┐
│ CLEARTAB: Cleans the comment buffer │
└──────────────────────────────────────────────────────┘
*/
void ClearTab(void)
{
memset (CmTab,0,MAX_C_LINES *( MAX_C_COLS + 1) );
}
/*---------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ PRINTTAB : Prints the current file description on stdout, and in │
│ the destination file list. │
╘════════════════════════════════════════════════════════════════════════╛
*/
void PrintTab(void)
{
int i;
for( i = 0 ; CmTab[i][0]; i++)
{
if( i ) CmTab[i][31] = '|' ;
printf ( "%s\n",CmTab[i] );
fprintf(dfile,"%s\n",CmTab[i] );
}
}
/*--------------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ MAKECONFPATH: Creates the full path and name of the config file, │
│ from the argv[0] program arg. │
│ │
╘════════════════════════════════════════════════════════════════════════╛
*/
void MakeConfPath(char *path)
{
int i;
strcpy(ConfPath,path);
i = strlen(ConfPath);
while(i)
{
if(ConfPath[i] == '\\' || ConfPath[i] == ':') break ;
ConfPath[i] = 0;
i--;
}
strcpy(TmpFile,ConfPath);
strcat( ConfPath,CONFIG_FILE );
strcat( TmpFile,TMP_FILE );
}
/*----------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ READCONF: Reads the config file. │
│ Return 1 on success │
│ 0 on error │
╘════════════════════════════════════════════════════════════════════════╛
*/
int ReadConf(void)
{
FILE *fp;
char tmp[ 256 ];
int count;
if( (fp = fopen(ConfPath,"r")) == NULL )
{
printf("Unable to open Config File : %s\n",ConfPath);
printf("You must create this file before using this program...\n\n");
SampleConfig();
printf("A sample one has been created for you.\n");
printf("Look at the file : %s with your favourite text editor !\n",
ConfPath);
return(0);
}
count = 0 ;
printf("Reading Config...\r");
while(fgets(tmp,255,fp ) )
{
Clean(tmp );
strupr(tmp );
if(strlen(tmp) < 2 ) continue ; /* Empty lines not used */
if(tmp[0] == COMMENT_CHAR ) continue ; /* Commented lines.. */
switch( count )
{
case 0 : /* 1st line : Directory where files */
strcpy( ScanDir, tmp );/* are downloaded. */
break ;
case 1 :
strcpy(FileDes,tmp ); /* 2nd line : Full name of the file */
break ; /* containing descriptions. */
case 2 :
strcpy(DestDir, tmp ); /* 3rd line : Destination Directory */
break ;
case 3 : /* 4th line : Full name of the BBS */
strcpy(FileList,tmp); /*description file to be updated */
break ;
case 4 : /* 5th line : Full name of the Batch */
strcpy(ExtCommand,tmp);/*optionnal command */
break ;
}
count++ ;
if( count > 5 )
{
printf("Too many config lines !!! Invalid file...\n" );
fclose(fp);
return(0);
}
}
fclose(fp);
return( 1 );
}
/*--------------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ VERIFPATH: Verifies filenames and pathnames. │
│ Return 1 on success │
│ 0 on error │
╘════════════════════════════════════════════════════════════════════════╛
*/
int VerifPath(void)
{
int RetVal = 1 ;
int echar ;
if( access( ScanDir, 0 ) )
{
printf("Invalid Source Directory %s\n",ScanDir );
RetVal = 0 ;
}
if( access( FileDes, 0 ) )
{
printf("Invalid Filename %s\n",FileDes );
RetVal = 0 ;
}
if(ExtCommand[0] >32 )
if( access( ExtCommand, 0 ) )
{
printf("Invalid External Command File %s\n",ExtCommand );
RetVal = 0 ;
}
if( access( DestDir, 0 ) )
{
printf("Invalid Destination Directory %s\n",DestDir );
RetVal = 0 ;
}
/* Prepares the Destination directory name for */
/* correct concatenation */
echar = (int) DestDir[strlen(DestDir) -1] ;
if( echar && echar != '\\' && echar != '/' && echar != ':' )
strcat(DestDir,"\\");
/* FileList not tested, it will be created if needed. */
return( RetVal );
}
/*----------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ MOVEFILE : Renames the file in order to have it in the destination │
│ directory. │
│ Return : 1 on success │
│ 0 on error │
│ Doesn't use rename() in order to be able to move files │
│ to different physical supports. │
╘════════════════════════════════════════════════════════════════════════╛
*/
int MoveFile(char *name)
{
char tmp[256];
char fullpath[256];
strcpy(fullpath,ScanPath);
strcat(fullpath,name );
if( ExtCommand[0] > 32 )
{
sprintf(tmp,"%s %s",ExtCommand,fullpath);
printf("Calling External Command for %s...\n",fullpath);
/* spawnlp(P_WAIT,ExtCommand,ExtCommand,fullpath,NULL);*/
system(tmp);
}
if (access(fullpath,0 ) )
return ( 0 ) ;
/* Explanation about the above silly lines... */
/* The User may need to process the file and */
/* eventually remove it or something else. */
/* It is impossible to use correctly a child */
/* process and get his return value under this*/
/* !$&çà"é MS-DOS !!! */
/* (spawn could have done it but does not work*/
/* with batch files... ) */
/* So the only thing we will do is to verify */
/* the acces to the file , and pray... :-) */
RealStat(fullpath,name); /* Date or size may have been modified... */
strcpy( tmp,DestDir );
strcat(tmp,name);
if( fmove(fullpath,tmp) )
{
printf("Unable to move %s to %s !\n", fullpath,tmp );
return( 0 );
}
return ( 1 );
}
/*------------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ FMOVE : Moves source File to dest File, using a fast copy routine │
│ │
│ Return : 0 on success │
│ 1 on error │
╘════════════════════════════════════════════════════════════════════════╛
*/
fmove(char *source, char *destin)
{
int src,
dst;
int perm = S_IREAD | S_IWRITE ;
int acc = O_RDWR | O_BINARY | O_CREAT | O_TRUNC ;
int nb;
char buf[MYBUFS];
#ifdef __TURBOC__
struct ftime df;
#else
unsigned df,
tf;
#endif
if( ( src = open (source,O_RDONLY | O_BINARY) ) == -1 )
{
printf("Unable to read file %s\n",source );
return( 1 );
}
#ifdef __TURBOC__
getftime(src,&df); /* Get the original file date ! */
#else
_dos_getftime(src,&df,&tf);
#endif
if( ( dst = open (destin,acc,perm) ) == -1 )
{
printf("Unable to create file %s\n",source );
Perror("System Report");
return( 1 );
}
while( (nb = read ( src, buf, MYBUFS )) )
write( dst,buf,nb );
#ifdef __TURBOC__
setftime(dst,&df); /* Set the original file date ! */
#else
_dos_setftime(dst,df,tf);
#endif
close( src );
close( dst );
if( unlink(source) == -1 )
{
printf("Unable to remove %s !\n", source );
Perror("System Report");
/* Not a real error,return OK. */
}
return( 0 );
}
/*-----------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ FAPPEND : Appends source File to dest File, trying to manage with │
│ sharing errors,I don't understand why this doesn't work │
│ like in **IX systems whith C-language and DOS! │
│ Here is a quick & dirty method... But I do not want to │
│ waste time learning those specific stuff which I'll │
│ never use... :-) │
│ │
│ Removes Source file on succes. │
│ │
│ Return : 0 on success │
│ 1 on error │
╘════════════════════════════════════════════════════════════════════════╛
*/
int fappend(char *destin, char *source )
{
int src,dst,
try = 10,
nb,result;
char buf[ MYBUFS ];
printf("Updating file %s...\n",destin);
if( ( src = open( source, O_RDONLY | O_BINARY ) ) == -1 )
{
printf("Error opening file %s !\n",source);
return ( 1 );
}
while( try-- )
{
dst = sopen( destin,
O_RDWR | O_APPEND | O_CREAT | O_BINARY,
SH_DENYWR , S_IWRITE );
if( dst == - 1 )
{
switch( errno )
{
case EMFILE :
printf(" Too many files opened !!!!!!! "
" Check your system configuration !!!\n");
return( 1 );
case EACCES :
if( try < 1 ) return (1);
printf("File busy...? Try %d\r",10 - try );
sleep( 2 ); /* Wait 2 seconds */
break ;
default :
Perror("System Report") ;
return ( 1 );
}
}
else break ; /* File sucessfully opened */
}
while( (nb = read ( src, buf, MYBUFS ) ) )
{
result = write( dst,buf,nb );
if( result == -1 )
{
printf("Error Writing file %s !\n",destin);
close ( src );
close ( dst );
return ( 1 );
}
}
close ( src );
close ( dst );
if ( unlink(source) != 0 )
{
printf("Unable to remove %s : ",source);
Perror("");
return( 1 );
}
return ( 0 ) ;
}
/*
╒════════════════════════════════════════════════════════════════════════╕
│ REALSTAT : Puts the real date & size of the filename in the comment.│
│ │
╘════════════════════════════════════════════════════════════════════════╛
*/
#define C_OFFSET 33 /* Comment text seems to begin at column 33 ... */
void RealStat(char *fullpath,char *name)
{
struct stat st ;
struct tm *tim ;
char comment[256];
int i;
for( i = 0; CmTab[0][i + C_OFFSET] ; i++ )
comment[i] = CmTab[0][i+ C_OFFSET];
comment[i] = 0;
/* Comment text seems to begin at column C_OFFSET ... */
/* Save it, and take the real file stats */
stat(fullpath ,&st);
tim = gmtime( &st.st_atime );
sprintf(CmTab[0],"%-12s %7ld %02d-%02d-%02d %s",
strupr(name),
st.st_size,
tim->tm_mon +1,
tim->tm_mday,
tim->tm_year,
comment);
/* I don't test the COUNTRY variable in **environ, this is */
/* The US date format... */
}
/*--------------------------------------------------------------------------*/
/*
╒════════════════════════════════════════════════════════════════════════╕
│ PERROR : Perror() is a replacement for perror(),writing on stdout │
│ instead of stderr. │
╘════════════════════════════════════════════════════════════════════════╛
*/
void Perror(char *s)
{
printf("%s : %s\n",s,sys_errlist[errno] );
}
/*------------------------------------------------------------------------*/
#ifndef __TURBOC__
/*
╒════════════════════════════════════════════════════════════════════════╕
│ SLEEP : quick implementation of function sleep(), non existent │
│ in Microsoft - C... !!!! │
╘════════════════════════════════════════════════════════════════════════╛
*/
sleep(unsigned sec)
{
long t1,t2;
time (&t1);
t2 = t1;
t1+= (long) sec;
while( t2 < t1 )
time (&t2 );
}
/*------------------------------------------------------------------------*/
#endif
/*
╒════════════════════════════════════════════════════════════════════════╕
│ SAMPLECONFIG: Creates a sample configuration file if possible. │
│ │
╘════════════════════════════════════════════════════════════════════════╛
*/
void SampleConfig(void)
{
FILE *fp;
if( (fp = fopen(ConfPath,"w")) == NULL ) return ;
fprintf(fp,"#----------------------------------------------------------\n");
fprintf(fp,"# This is a sample configuration file for ADD2BBS.EXE. \n");
fprintf(fp,"# Replace the pathnames & directories by your own values. \n");
fprintf(fp,"#----------------------------------------------------------\n");
fprintf(fp,"# Below is the name of the directory where the program \n");
fprintf(fp,"# will look for the files you want to move : \n");
fprintf(fp,"#\n\n");
fprintf(fp,"C:\\FILE2MOV\n\n");
fprintf(fp,"#\n");
fprintf(fp,"#----------------------------------------------------------\n");
fprintf(fp,"# Below is the Full Name and Pathname of the file \n");
fprintf(fp,"# containing the descriptions corresponding to the files : \n");
fprintf(fp,"#\n\n");
fprintf(fp,"C:\\FIL2MOVE\\INPUT.DSC\n\n");
fprintf(fp,"#\n");
fprintf(fp,"#----------------------------------------------------------\n");
fprintf(fp,"# Now, the directory where you want to move the files to: \n");
fprintf(fp,"#\n\n");
fprintf(fp,"C:\\FILMOVED\n\n");
fprintf(fp,"#\n");
fprintf(fp,"#----------------------------------------------------------\n");
fprintf(fp,"# Here, the full Name and Pathname of the description \n");
fprintf(fp,"# file you want to update or create :\n");
fprintf(fp,"#\n\n");
fprintf(fp,"C:\\FIL2MOVE\\OUTPUT.DSC\n\n");
fprintf(fp,"#\n");
fprintf(fp,"#----------------------------------------------------------\n");
fprintf(fp,"# Finally the full pathname of an optionnal batch file,\n");
fprintf(fp,"#\n");
fprintf(fp,"# It will be called by the program with the current\n");
fprintf(fp,"# filename as argument ( e.g ' TESTFIL.BAT 2BEMOVED.ZIP')\n");
fprintf(fp,"# just BEFORE moving the file.\n");
fprintf(fp,"#\n");
fprintf(fp,"# (This can be used to SCAN a ZIP file for virii, \n");
fprintf(fp,"# remove a ZIP comment, add a new one, etc ...) \n");
fprintf(fp,"#\n");
fprintf(fp,"# Leave this field blank if no special processing needed.\n");
fprintf(fp,"#\n\n");
fprintf(fp,"TESTFILE.BAT\n\n");
fprintf(fp,"#\n");
fprintf(fp,"#----------------------------------------------------------\n");
fclose(fp);
}
/*------------------------------------------------------------------------*/
void Usage(void)
{
printf("Usage : ADD2BBS source_dir source_list dest_dir dest_list\n\n");
printf(" Configuration file is used if no argument.\n");
}
/*------------------------------------------------------------------------*/
void Title(void )
{
printf(
"\t\t╒═════════════════════════════════════════╕\n"
"\t\t│ Add2bbs: Public Domain PcBoard Utility │\n"
"\t\t│ by René COUGNENC & Attila ALTAN │\n"
"\t\t│ France - 1990 │\n"
"\t\t╘═══════════════════════════════════[%3s]═╛\n"
"\n", ___VERSION___
);
}
/*-------------------------------------------------------------------------*/
/*=====================( End of add2bbs.C )================================*/
#ifdef NOT_USED_PERHAPS_ONE_DAY
/*
╒════════════════════════════════════════════════════════════════════════╕
│ LASTFILES: Scans the linked list for the undescribed files. │
│ Moves them to the destination directory, and write an │
│ empty comment to the destination description file. │
│ │
╘════════════════════════════════════════════════════════════════════════╛
*/
void LastFiles(void)
{
struct Ftype *WorkStru;
struct stat st ;
struct tm *tim ;
WorkStru = Fstru ;
while( WorkStru -> Next != (struct Ftype *) NULL )
{
if (! WorkStru->HasComment )
{
stat(WorkStru -> fname ,&st);
tim = gmtime( &st.st_atime );
sprintf(CmTab[0],"%-12s %7ld %02d-%02d-%02d %s",
strupr(WorkStru->fname),
st.st_size,
tim->tm_mon +1,
tim->tm_mday,
tim->tm_year,
NullComment);
CmTab[1][0] = 0;
if( MoveFile( WorkStru -> fname ) )
{
printf("───── Not Found : %s ───────────────────────\n",WorkStru -> fname );
PrintTab();
printf("----- File moved.---------------------------\n");
}
}
WorkStru = WorkStru -> Next ;
}
}
/*--------------------------------------------------------------------------*/
#endif